#include <stdio.h>
#include <string.h>
#include "io_mng.h"
#include "encoder_logger.h"
#include "h264_ctx.h"
#include "encode.h"

#define INPUT_FILE "/home/tsw/h264_self/build/128x128_yuv420p.yuv"
#define PIC_WIDTH 128
#define PIC_HEIGHT 128

int main(int argc, char const *argv[])
{
    printf("============H264 Encode Start!=============\n");
    input_img_ctx_t input_ctx = {0};
    strncpy(input_ctx.filename, INPUT_FILE, sizeof(input_ctx.filename) - 1);
    input_ctx.width = PIC_WIDTH;
    input_ctx.height = PIC_HEIGHT;

    int ret = read_data_to_input_ctx(&input_ctx, PIX_FMT_YUV420P);
    if (ret < 0) {
        ERR_LOG("read_data_to_input_ctx failed ret %d\n", ret);
        return -1;
    }

    INFO_LOG("y data[0] %02x u data[0] %02x v data[0] %02x\n", 
            input_ctx.plane.y_data[0], input_ctx.plane.u_data[0], input_ctx.plane.v_data[0]);
    h264_ctx_t h264_ctx = {0};
    init_h264_ctx(&input_ctx, &h264_ctx);
    h264_encode(&h264_ctx);
    return 0;
}
